Syntax.Comments
Each comment must start with #
(space hash). Everything following in that line is comment and will be removed from output
If your pattern uses #
, escape it like \#
Syntax.Functions
::functionName(arg1 ;; arg2 ;; arg3) ## Comments if you want
- The function must be the only thing on the line. Comments allowed.
- Args must not be quoted. Every arg will be trimmed (surrounding whitespace is removed).
- Args are separated by ' ;; ' (space semicolon semicolon space)
Syntax.Refs
Functions can accept a refs list as an argument. Each ref is closed in double moustaches {{refname}}
## Combine selected refs with the bar (|) separator
::combine( {{ref1}}{{ref2}}{{ref3}} ;; |)
Each ref name can be composed of a-z
, A-Z
, 0-9
, and/or special chars: . - _
Example.Simple
$dataSet = [ 'one'=> 'one ::ref(two)', // 'one'=> 'one ::ref(two ;; {{na}}{{cool}}{{happy}})', 'two'=> 'two ::ref(three)', 'three'=> 'three' ]; $startReg = $dataSet['one']; // $funcHandler = new \RegWithSimpleArray($dataSet); $br = new \RegWithSimpleArray($dataSet);
$finalReg = $br->parse($startReg); $targetReg= 'one two three'; // $finalReg == $targetReg
Example.Cleaning.Src
<<<REGEX One #a comment at the start
Another start of line comment
#\
\
eol_esc_slash\\\\\\
eol_space_test\\\\\
abc\ #Should this be a comment? It IS, only because making it NOT a comment is much more complicated & harder to communicate.
def\ #this IS a comment
ghi\ #this is not a comment
jkl\\ #this IS a comment
#
\ Two # Am a comment
( ( # Am another comment
#Three # This seems like a lot of comments
#[0-9] # You need escape your # lie # to use a space + hash as not-a-comment
))?
REGEX,
Example.Cleaning.Target
'One\#\ \ \ eol_esc_slash\\\\\\eol_space_test\\\\\ abc\ def\ ghi\ \#this is not a commentjkl\\\ Two( (#Three))?',
Example.AnimalStuffsReg
::funcName(arg1 ;; arg2 ;; {{BabySeal}}{{HappyCat}}{{FunnyGiraffe}})
Example.AnimalStuffsOut
arg1-arg2-FunnyGiraffe
Example.AnimalStuffsClass
class AnimalStuffs extends BetterReg {
public function regFuncName($namespace, $arg1, $arg2, $animals){
$arg1 == 'arg1';
$arg2 == 'arg2';
$animals == ['BabySeal','HappyCat','FunnyGiraffe'];
return $arg1.'-'.$arg2.'-'.$animals[2];
}
}